(function($)
{
    /**
     * Auto-growing textareas; technique ripped from Facebook
     *
     * http://github.com/jaz303/jquery-grab-bag/tree/master/javascripts/jquery.autogrow-textarea.js
     */
    $.fn.adminDatePicker = function(options)
    {
        var $self = $(this);
        $self.hide();
        var $parent=$self.parent();
        var org_val=$(this).val();
        var org_dateMs=Date.parse(org_val);
        var org_date=null;
        if(isNaN(org_dateMs)){
        	org_date=new Date();
        }else{
        	org_date=new Date(org_dateMs);
        }
        var org_year=org_date.getFullYear();
        var org_month=org_date.getMonth();
        var org_day=org_date.getDay();
        var $year_Select=null;
        if($parent.find("select[name=date_year]").length==0){
        	$year_Select=$("<select name=\"date_year\" class=\"input-mini\"/>");
            $year_Select.appendTo($parent)
        }else{
        	$year_Select=$parent.find("select[name=date_year]").html("");
        }
        var $month_Select=null;
        if($parent.find("select[name=date_month]").length==0){
        	$month_Select=$("<select name=\"date_month\" class=\"input-mini\"/>");
            $month_Select.appendTo($parent)
        }else{
        	$month_Select=$parent.find("select[name=date_month]").html("");
        }
        var $day_Select=null;
        if($parent.find("select[name=date_day]").length==0){
        	$day_Select =$("<select name=\"date_day\" class=\"input-mini\"/>");
            $day_Select.appendTo($parent)
        }else{
        	$day_Select=$parent.find("select[name=date_day]").html("");
        }
        for(i=org_year-1;i<=org_year+1;i++){
        	$("<option/>").val(i).html(i).appendTo($year_Select);
        }
        //for(i=org_month)
    }
})(jQuery);